package pay.biz;

/**
 * @author suan
 */
public enum ApayTradeStatusEnum {

    FINISHED("TRADE_FINISHED", "交易成功且结束，即不可再做任何操作"),

    SUCCESS("TRADE_SUCCESS", "交易成功"),

    CLOSED("TRADE_CLOSED", "超时关闭"),

    WAIT_PAY("WAIT_BUYER_PAY", "等待买家付款"),

    PENDING("TRADE_PENDING", "等待卖家收款"),

    UNKNOWN("UNKNOWN", "未知状态"), // 非支付宝交易的实际状态值，应用用于接口异常，不明确实际状态情况

    FAILED("FAILED", "交易失败"), // 非支付宝交易的实际状态值，应用用于接口异常

    // 全额退款情况：trade_status=
    // TRADE_CLOSED，而refund_status=REFUND_SUCCESS；非全额退款情况：trade_status=
    // TRADE_SUCCESS，而refund_status=REFUND_SUCCESS
    REFUND_SUCCESS("REFUND_SUCCESS", "退款成功"),

    REFUND_CLOSED("REFUND_CLOSED", "退款关闭"),

    ;

    /** 业务分类名称 */
    private String code;

    /** 业务分类描述 */
    private String description;

    /**
     * 构造函数
     * 
     * @param code
     * @param description
     */
    private ApayTradeStatusEnum(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public static ApayTradeStatusEnum getEnumByCode(String code) {

        for (ApayTradeStatusEnum tmpEnum : ApayTradeStatusEnum.values()) {
            if (tmpEnum.getCode().equalsIgnoreCase(code)) {
                return tmpEnum;
            }
        }

        return null;
    }

    /**
     * @return the code - {返回值描述信息}.
     */
    public String getCode() {
        return code;
    }

    /**
     * @param code
     *            to set - {参数含义描述}.
     */
    public void setCode(String code) {
        this.code = code;
    }

    /**
     * @return the description
     */
    public String getDescription() {
        return description;
    }

    /**
     * @param description
     *            the description to set
     */
    public void setDescription(String description) {
        this.description = description;
    }
}
